<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

//echo("Ardress:" . $client_address . "Invoice Number:" . $invoice_number);
GLOBAL $title,$desc,$rate;
$i=0;
for ($i=0;$i<(count($task_details));$i++)
	{ 
		//print_r($task_details);
		//exit;
		$title[$i] = $task_details[$i]['title'];
		//echo("Title".$i .":". $title[$i]);
		$desc[$i] = $task_details[$i]['desc'];
		//echo("Descp".$i .":". $desc[$i]."<br/>");
		//print_r ($rates_custom[$i]);
		$rate[$i] = $rates_custom[$i]['rate'];
			
	
			
	}	
?>
<html>
	<head>
		<title>Invoice
		</title>
		<script src="<?=base_url()?>assets/js/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" href="<?=base_url()?>assets/css/base.css" type="text/css" media="screen,print" title="" charset="utf-8">
		<script src="<?=base_url()?>assets/js/invc.js" type="text/javascript" charset="utf-8"></script>
		
</head>
<body onload="maincalc()">
	<div class="huh">
		<div class="options">
					
					<a href="#" onClick="print_doc()" >Print</a>
					<a href="#" onClick="save()">Save</a>
					<a href="#" onClick="pdf()">Download PDF</a>
				</div>

				<div id="page">
				<form action="pdf.php" id="form" method="post" class="body">

					<div class="letterhead">
			
					<input name="kind" id="kind" type="text" value="INVOICE" autocomplete="off" style="background-color: rgb(250, 251, 251);">
					<textarea id="company_name" name="company_name" spellcheck="false" autocomplete="off" style="overflow: hidden; background-color: rgb(250, 251, 251);">Fedobe Solutions Pvt Ltd</textarea>
					<textarea id="company_info" name="company_info" spellcheck="false" autocomplete="off" style="overflow: hidden; background-color: rgb(250, 251, 251);">www.fedobe.com&#10;mail@fedobe.com</textarea>
			
					</div>

					<div class="info">
					
						<textarea id="recipient_info" name="recipient_info" spellcheck="false" autocomplete="off" style="overflow: hidden; background-color: rgb(250, 251, 251);"><?php if(isset($client_address) OR !empty($client_address))echo($client_address); else echo(" "); ;?></textarea>
						<table id="invoice_info">
							<tbody>
							
								<tr>
									
									<th>
										<input type="text" id="invoice_number_label" name="invoice_number_label" value="Invoice #" autocomplete="off" style="background-color: rgb(250, 251, 251);">
									</th>
									
									<td>
										<input type="text" id="invoice_number" name="invoice_number" value="<?php if(isset($invoice_number)) echo($invoice_number); else echo("1");?>" autocomplete="off" style="background-color: rgb(250, 251, 251);">
									</td>
								
								</tr>
					
								<tr>
									
									<th>
										<input type="text" id="invoice_date_label" name="invoice_date_label" value="Date" autocomplete="off" style="background-color: rgb(250, 251, 251);">
									</th>
									
									<td>
										<input type="text" id="invoice_date" name="invoice_date" value="<?php $mydate=getdate(date("U"));echo($mydate['month']." " . $mydate['mday']. "," . $mydate['year']);?>" autocomplete="off" style="background-color: rgb(250, 251, 251);">
									</td>
								</tr>
							</tbody>
						</table>
					</div>


        <table id="items">
            <thead>
                <tr>
                    <td class="action">&nbsp;
					</td>
                    <th class="description" width="50%">
					<input type="text" id="description_label" name="description_label" value="Item & Description" autocomplete="off" style="background-color: rgb(250, 251, 251);">
					</th>
					<th class="rate" width="15%">
					<input type="text" id="rate_label" name="rate_label" value="Rate" autocomplete="off" style="background-color: rgb(250, 251, 251);">
					</th>
                    <th class="quantity"width="15%">
					<input type="text" id="quantity_label" name="quantity_label" value="Time" autocomplete="off" style="background-color: rgb(250, 251, 251);">
					</th>
                    <th class="price" width="15%">
					<input type="text" id="price_label" name="price_label" value="Price" autocomplete="off">
					</th>
                    <td class="action">&nbsp;</td>
                </tr>
            </thead>
			
			
			<?php for($i=0;$i<count($title);$i++)
					{
			?>
			
			
            <tr>
				<td class="action">
				</td>
				<td class="description">
					<textarea name="items_descp[]" id="items_descp<?php echo $i;?>" task_id="<?php echo($box[$i]);?>" style="overflow: hidden; height: 36px; background-color: rgb(250, 251, 251);"><?php echo($title[$i] . "-" . $desc[$i]);?></textarea>
				</td>
				<td class="rate">
					<input type="text" name="items_rate[]" id="items_rate<?php echo $i;?>" value="<?php echo($rate[$i]); ?>" onBlur="maincalc()" style="background-color: rgb(250, 251, 251);">
				</td>
				<td class="quantity">
					<input type="text" name="items_qty[]" id="items_qty<?php echo $i;?>" value="<?php echo($time_left[$i]);?>" onBlur="maincalc()" style="background-color: rgb(250, 251, 251);">
				</td>
				<td class="price">
					<input type="text" name="items_prc[]" id="items_prc<?php echo $i;?>" value="00.00" onBlur="maincalc()">
				</td>
				<td class="action">
					<a href="#" onclick="del_row(this)">[ x ]</a>
				</td>
			</tr>
			<?php  }?>
			<tfoot>
                <tr>
					<td class="action">
					</td>
                    <td colspan="4">
                    <a href="#" onclick="add_row()">[ + ]</a>
                    </td>
                    <td class="action">
					</td>
                </tr>
            </tfoot>
			
			
			
        </table>



        <div class="summary">
            <table>
                <tbody>
					<tr>
						<th>
							<input type="text" name="subtotal_label" id="subtotal_label" value="Subtotal" autocomplete="off">
						</th>
						<td></td>
						<td>
							<span id="subttl_spn" class="subtotal">0.00</span>
							<input type="hidden" id="subttl" name="subtotal" class="subtotal" autocomplete="off" value="0.00">
						</td>
					</tr>
					<tr >
						<th>
							<input type="text" id="tax_name" name="tax_name" value="VAT" autocomplete="off">
						</th>
						<td >
							<input type="text" name="tax_percentage" id="tax_percentage" value="12.5" autocomplete="off" size="2" style="width:20%">
							<span id="tax_percentage" class="tax_percentage">%</span>
						</td>
						<td>
							<span id="tax_amount_spn" class="tax_amount">0.00</span>
							<input type="hidden" id="tax_amount" name="tax_amount" class="tax_amount" autocomplete="off" value="0.00">
						</td>
					</tr>
					<tr>
						<th>
							<input type="text" name="discount_label" id="discount_label" value="Discount" autocomplete="off" style="background-color: rgb(250, 251, 251);">
						</th>
						<td>
							<input type="text" name="currency_symbol" id="currency_symbol" value="Rs" autocomplete="off">

						</td>
						<td>
							
							<input type="hidden" id="discount" name="discount" class="discount" autocomplete="off" value="0.00">
						</td>
					</tr>
					
					<tr>
						<th>
							<input type="text" name="total_label" id="total_label" value="Total" autocomplete="off" style="background-color: rgb(250, 251, 251);">
						</th>
						<td>
							<input type="text" name="currency_symbol" id="currency_symbol" value="Rs" autocomplete="off">

						</td>
						<td>
							<span id="total_spn" class="total">0.00</span>
							<input type="hidden" id="total" name="total" class="total" autocomplete="off" value="0.00">
						</td>
					</tr>
				</tbody>
			</table>
        </div>


        <div class="notes">
            <textarea id="notes_a" name="notes_a" spellcheck="false" autocomplete="off" style="overflow: hidden; background-color: rgb(250, 251, 251);">Created with Fedobe.com</textarea>
            <textarea id="notes_b" name="notes_b" spellcheck="false" autocomplete="off" style="overflow: hidden; height: 45px; background-color: rgb(250, 251, 251);"></textarea>
        </div>
	    </form>
	</div>	
	</div>
</body>	
</html>	